<%@ page import="java.util.Vector,com.ejoysoft.wlanyz.system.User,com.ejoysoft.wlanyz.system.SysUserUnit,com.ejoysoft.wlanyz.system.Unit,
                 java.util.HashMap,com.ejoysoft.common.Constants,com.ejoysoft.common.exception.NoRightException"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="../include/jsp/head.jsp"%>
<%
if(!globa.userSession.hasRight("50015"))
      throw new NoRightException("用户不具备操作该功能模块的权限，请与系统管理员联系！");
%> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
<link href="../common/css/css.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><style type="text/css">
<!--
body {
	background-color: #f2f8ff;
}
.sel1{ width:160px;}
.STYLE1 {color: #FF0000} 
.a1:link{ font-size:12px; color:#333333; text-decoration:none }
.a1:visited { font-size:12px; color:#333333; text-decoration:none }
.a1 a{ font-size:14px;color:#333333;  text-decoration:none}
-->
</style>
<script src="../include/js/list.js"></script>
<script src="../js/jquery-1.4.1.min.js"></script>
<script language="javascript">
function expand(obj, gid) {
    var oGid = eval("document.all." + gid);
    if (obj.value == "+") {
        obj.value = "-";
        if(oGid!=undefined)
        if (oGid.length == undefined)
            oGid.style.display = "";
        else
            for (var i = 0; i < oGid.length; i++)
                oGid[i].style.display = "";
    } else {
        obj.value = "+";
        if(oGid!=undefined)
        if (oGid.length == undefined)
            oGid.style.display = "none";
        else
            for (var i = 0; i < oGid.length; i++)
                oGid[i].style.display = "none";
    }
}
function rightSet() {
    for (var i = 0; i < frm.sel.length; i++)
        if (frm.sel[i].checked)
            window.open("right_set.jsp?sel=" + frm.sel[i].value, "权限分配", "width=370,height=650,top=20,left=50,scrollbars=yes,status=yes");
}
</script>
</head>


<body>
<form id=frm name=frm method="post" action="">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="8FA6BD">
  <tr>
    <td height="28" background="../images/ri_bg.jpg"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="2%" valign="top"><img src="../images/ri_1.jpg" width="25" height="28" /></td>
        <td class="a0">权限分配</td>
        <td style="width: 145px" align="right">
        <table border="0" cellspacing="0" cellpadding="0">
          <tr>
			<td valign="top" align="right"><img src="../images/add.jpg" height="28" onClick="add()" style="padding: 0px"/></td>
		    <td valign="top" align="right"><img src="../images/edit.jpg" height="28" onClick="update()" style="padding: 0px"/></td> 
			<td valign="top" align="right"><img src="../images/del.jpg"  height="28" onClick="del()" style="padding: 0px"/></td> 
			<td width="2%">&nbsp;</td>
		 </tr>
        </table></td>
        
      </tr>
    </table></td>
  </tr>
  <tr>
  <td bgcolor="#FFFFFF"  height="300" valign="top">
   <table width="92%" border="0" align="center" cellpadding="0" cellspacing="0"> 
   <tr><td  bgcolor="#FFFFFF"  height="40"><font size="2">操作提示：以下为部门及部门成员的树形结构，选定某部分或成员对该部门或成员用户进行权限分配操作。</font></td></tr>
   <tr> <td > 
   	 <table width="100%" border="0" cellspacing="0" cellpadding="0">
         <tr>
           <td align="center" style="width:23px" valign="bottom">  <input style="height: 23px" type="hidden" name="b_0000000000" id="b_0000000000" value="+" />
          <img id="imgg0000000000" src="../images/_plus0.gif" width="23" onclick="expand2(document.getElementById('b_0000000000'),'g0000000000','0');" /></td>
           <td style="height: 23px;" class="a0" valign="bottom"><span id="fileOCg0000000000"><img style="margin-bottom: 0px" src="../images/folder2.gif" width="16"/></span>&nbsp;&nbsp;&nbsp;&nbsp;部门机构</td>
        </tr>
      </table>
    </td>
   </tr>
     <tr>
      <td> 
       <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" id="g0000000000" style="display:none">
           <tr> 
           		<td align="center" style="width:23px">&nbsp;</td>
                <td  valign="top" >
                  <%
                     User user = new User(globa);
                    //获得所有用户并分组
                    HashMap allUsers = user.getUnitAllUser(" ORDER BY strUnitId  ASC");
          
                  	String unitId = "";
                  	if(globa.userSession.getStrUnitId()!= null && globa.userSession.getStrUnitId().length >0)
                  		unitId = globa.userSession.getStrUnitId()[0];
                    Vector userGroupTree = SysUserUnit.getUserGroupTree();  //树形目录的所有用户组向量
                    int curLevel = 1;
                    for (int i = 0; i < userGroupTree.size(); i++) {
                        Unit ug = (Unit)userGroupTree.get(i);
                        if (ug.getIntLevel() < curLevel) {   //上级用户�?
                             for (int j = ug.getIntLevel(); j < curLevel; j++) {  //输出收口标签
                %>
                    </td>
                  </tr>
                </table>
        <%
                     }
                }
        %>
        <table width="100%" border="0" align="center" cellspacing="0" cellpadding="0" id="g<%=ug.getStrParentId()%>" style="display:<%=ug.getStrParentId().equals("") ? "":"none"%>" class="td_color_1">
          <tr > 
          <% if(ug.isLastNode()){
           %>
            <td valign="top" style="width:23px">
            <%}else{ %>
              <td valign="top" background="../images/_line4.gif" style="width:23px">
            <%} %>
            <table width="100%" border="0" cellspacing="0" cellpadding="0" >
                <tr>
                  <td align="left" valign="bottom"><!--
        <%
                if (ug.haveChild()) {   //有下级用户组
        %>
       			   --><input class="input3" type="hidden"  name="b_<%=ug.getStrId()%>" id="b_<%=ug.getStrId()%>" value="+" ><!--
       		       <img id="imgg<%=ug.getStrId()%>" src="../images/_plus2.gif" width="23" onclick="expand2(document.getElementById('b_<%=ug.getStrId()%>'),'g<%=ug.getStrId()%>','2');" />
        <%   
                }  
                else{ 
	         %>  
	         	 <img id="imgg<%=ug.getStrId()%>" src="../images/_line2.gif" width="23" />
	           <%     
                }
        %>        --></td>
                </tr>
              </table>
            </td>
            
          <!--  <td align="left" style="padding-top: 0px;margin-top: 0px">
            <table border="0" cellspacing="0" cellpadding="0"><tr>
            <%
                if (ug.haveChild()) {   //有下级用户组
       		  %>
       		      <td valign="bottom" style="height: 23px"><span id="fileOCg<%=ug.getStrId()%>"><img alt="" src="../images/folderclose.gif" width="16"/></span></td>
       		  <%
       		  }else{
       		   %>
       		   <td valign="bottom" style="height: 23px"><img id="img0000000000" alt="" src="../images/file.gif" width="16" /></td>
       		   <%} %>
              <td valign="bottom" style="height: 23px"> <input style="border:0px ;height: 23px" name='strUnitId' type='radio' value='<%=ug.getStrId()%>'<%=SysUserUnit.isManaged(unitId, ug.getStrId()) && !unitId.equals(ug.getStrId()) || globa.userSession.getIntUserType() == 0 ? "" : " disabled"%>></td>
              <td valign="bottom" style="height: 23px"><a class="a1" href='unit_show.jsp?strId=<%=ug.getStrId()%>'><%=ug.getStrUnitName()%>/<%=ug.getStrUnitCode()%></a></td>
        -->
        <td align="left" style="padding-top: 0px;margin-top: 0px">
              <input  name='sel'  type='radio' value='g/<%=ug.getStrId()%>' <%=i == 0 ? " checked" : ""%>>
              <%=ug.getStrUnitName()%>
              <%
                if (allUsers.containsKey(ug.getStrId())) { //有用户，显示用户
                    for (int m = 0; m < ((Vector)allUsers.get(ug.getStrId())).size(); m++) {
                        User theUser = (User)((Vector)allUsers.get(ug.getStrId())).get(m);
        %>
        <table width="100%" border="0" align="center" cellspacing="0" cellpadding="0" id="g<%=ug.getStrId()%>" style="display:none">
          <tr>
            <td  height="22" valign="top" bgcolor="#F6F6F6">
              <table  border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="40" align="right"><font color="#FF0000">*</font>
                  <input  name='sel'  type='radio' value='u/<%=theUser.getStrId()%>'>
                  </td>
                </tr>
              </table>
            </td>
            <td width="92%" height="22">
              <%=theUser.getStrUserId()%><font color="#FF0000">／</font><%=theUser.getStrName()%>
            </td>
          </tr>
        </table>
        <%    }
                } 
                if (!ug.haveChild()) {  //没有下级用户组，直接收口
        %>
      		  </tr></table>
            </td>
          </tr>
        </table>
        <%
                }
                curLevel = ug.getIntLevel();
            }
            //最后收首尾
            for (int j = 1; j < curLevel; j++) {
        %>
        	</td>
           </tr>
        </table>
        <%
            } 
        %>
               <!-- end -->  
		</td>
      </tr>
   </table>
<p><br />
</p></form>
</body>
</html>
